package cn.lsoft.undoner.controller.message;

import java.util.Date;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import cn.lsoft.undoner.controller.BaseController;
import cn.lsoft.undoner.controller.user.UserController;
import cn.lsoft.undoner.dao.domain.User;
import cn.lsoft.undoner.model.view.ResponseMessage;
import cn.lsoft.undoner.service.message.MessageService;
import cn.lsoft.undoner.service.user.UserService;


/** 
* @ClassName: UserController 
* @Description: TODO(这里用一句话描述这个类的作用) 
* @author undoner@gmail.com
* @date 2017年1月21日 下午7:42:32 
*/
@Controller
@RequestMapping("/message")
public class MessageController implements BaseController {
	private static final Logger logger = LoggerFactory.getLogger(MessageController.class);
	@Resource
	private MessageService messageService;
	private ResponseMessage responseMessage;
	

	/** 
	* @Title: sendInfo 
	* @Description: TODO(这里用一句话描述这个方法的作用) 
	* @param @return    设定参数 
	* @return ResponseMessage    返回类型 
	* @throws 
	* @author undoner@gmail.com 
	* @date 2017年1月21日 下午8:27:14 
	*/
	@RequestMapping(value = "sendInfo", method = RequestMethod.GET)
	@ResponseBody
    public ResponseMessage sendInfo(){ 
		responseMessage=new ResponseMessage();
        try {
    		messageService.sendInfo("testTopic",new Date().toString()+"：kafka sendMessage test!");
            responseMessage.setCode(1);
            responseMessage.setMsg("success");
            responseMessage.setObject("");
        } catch (Exception e) {
            responseMessage.setCode(-1);
            responseMessage.setMsg(e.getMessage());
        }
        return responseMessage;
		
    }  
}
